using System;
using System.ComponentModel;

namespace MefBasic.Data
{
    [Serializable]
    public abstract class ANotifyPropertyChanged : INotifyPropertyChanged
    {
        #region INotifyPropertyChanged Members
        [NonSerialized]
        private PropertyChangedEventHandler _propertyChanged;
        public event PropertyChangedEventHandler PropertyChanged
        {
            add
            {
                _propertyChanged =
                    (PropertyChangedEventHandler)Delegate.Combine(_propertyChanged, value);
            }

            remove
            {
                _propertyChanged =
                    (PropertyChangedEventHandler)Delegate.Remove(_propertyChanged, value);
            }
        }
        public virtual void OnPropertyChanged(string propertyName)
        {
            if (_propertyChanged != null)
            {
                _propertyChanged(this, new PropertyChangedEventArgs(propertyName));
            }
        }
        #endregion
    }
}
